package com.example.sentineldemo.service;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.example.sentineldemo.handler.CommonBackHandler;
import com.example.sentineldemo.handler.ResourceKey;
import org.springframework.stereotype.Component;

/**
 * @author wangjinlong
 * @date 2022/2/15 17:37
 */
@Component
public class AccountQueryService {
    @SentinelResource(
            value = ResourceKey.KEY_ACCOUNT,
            blockHandlerClass = CommonBackHandler.class, blockHandler = "handleBlockException2",
            fallbackClass = CommonBackHandler.class, fallback = "handleAllException2"
    )
    public String queryAccountInfo() {
        int i = 10 / 0;
        return "account - 1";
    }

    @SentinelResource(
            value = ResourceKey.KEY_ACCOUNT,
            blockHandlerClass = CommonBackHandler.class, blockHandler = "handleBlockException2",
            fallbackClass = CommonBackHandler.class, fallback = "handleAllException2"
    )
    public String queryAccountInfo2() {
        int i = 10 / 0;
        return "account - 1";
    }
}
